package com.neuedu.javase.ext;

/**
 * @auth 金山老师
 * title:   书籍代码
 * creatime: 2022-09-26 16:31
 * 描述 : 动物类型
 */
//public final class Animal {
public  class Animal {
    String name;
    int age;

    static {
        System.out.println("1Animal.static initializer");
    }

    {
        System.out.println("Animal.instance initializer");
    }

    public Animal() {
        System.out.println("3-1  Animal构造器");
    }
    public Animal(String name) {

        this.name = name;
        System.out.println("3-2  Animal构造器");
    }
    public Animal(int age) {
        this.age = age;
        System.out.println("3-3  Animal构造器");
    }

    public Animal(String name,int age) {
        this(name); //调用本类的构造函数
        this.age = age;
        System.out.println("3-3  Animal构造器");
    }


    void eat(){
        System.out.println("正在吃饭1");
        System.out.println("正在吃饭2");
        System.out.println("正在吃饭3");
        System.out.println("正在吃饭4");
    }


    public static void main(String[] args) {

        Animal animal = new Animal();


    }

}
